package com.fish.order.dao;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.fish.account.po.Account;
import com.fish.common.constant.QueryPage;
import com.fish.common.dao.BaseIbatisDao;
import com.fish.order.po.Order;

public class OrderDAO extends BaseIbatisDao{

	private static final Log loger = LogFactory.getLog(OrderDAO.class);
	public OrderDAO() {
		super();
	}

	/**
	 * 根据主键查询
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	public Order queryOrderByPrimaryKey(Long orderId) {
		return (Order) this.getSqlMapClientTemplate().queryForObject("ORDER.selectByPrimaryKey", orderId);
	}

	/**
	 * 模糊查询
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	@SuppressWarnings("unchecked")
	public List<Order> queryOrderByObject(Order order) {
		return (ArrayList<Order>) this.getSqlMapClientTemplate().queryForList("ORDER.queryByOrder", order);
	}

	/**
	 * 添加
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	public void addOrder(Order order) {
		this.getSqlMapClientTemplate().insert("ORDER.insert", order);
	}
	
	/**
	 * 修改
	 * 
	 * @update zhangzhenhua 2010-9-20
	 */
	public void updateOrder(Order order) {
		this.getSqlMapClientTemplate().update("ORDER.updateByPrimaryKeySelective", order);
	}
	
	public Long queryOrderCountByObject(Order order){
		return  (Long) this.getSqlMapClientTemplate().queryForObject("ORDER.countOrderWithPaging", order);
	}
	
	public  List<Order> queryOrderObject(Order order,QueryPage queryPage){
		order.setBeginItem(queryPage.getBeginItem());
		order.setEndItem(queryPage.getPageSize());
		return (List<Order>) this.getSqlMapClientTemplate().queryForList("ORDER.selectOrderWithPaging", order);
	}	
}